#ifndef slak_tetris_renderer_h
#define slak_tetris_renderer_h

#include <string>
#include "tetrad.h"
#include "slak/glui/label.h"
#include "slak/glui/overlay.h"

namespace slak {
	namespace tetris {

		struct Game;

		struct Renderer : slak::glui::Overlay {
			static const int block_size = 32;

			static const float state_colours[N_STATES][3];
			
			unsigned int texture_ids[N_STATES];
			int field_x0; 
			int field_x1;
			int field_y0; 
			int field_y1;

			Game * g;
			slak::glui::Label score_lbl, level_lbl;

			Renderer(Game * g);
			~Renderer();

			void loadTextures();

			void draw();
			void drawField();
			void drawBlocksPass(square_state st, 
					   float x0 = -1, float y0 = -1);
			void drawBlocks();
			void drawScore();
			void drawLevel();
			void drawNextTetrad();
			void blockXY(int i, int j, float& x, float& y,
				    float x0 = -1, float y0 = -1);
		};

	}
}

#endif
